package com.yht.downloadimage.storage;

import java.util.LinkedList;

public class NumStorage {
private static LinkedList<Integer> numList=new LinkedList<Integer>();
	
	public synchronized static void initNumList(int Num1,int Num2){
		if(Num1<=0||Num2<=0){
			System.out.println("输入了非法的参数，参数必须大于0");
		}else if(Num1>Num2){
			System.out.println("输入了非法的参数，参数1必须不大于参数2");
		}else{
			for(int i=Num1;i<=Num2;i++){
				numList.add(i);
			}
		}
	} 
	
	public synchronized static void addNum(int num){
		numList.add(num);
	}
	
	public synchronized static int getNum(){
		if(numList.size()==0){
			return 0;
		}
		return numList.poll();
	}
}
